package cc.lzmsh.service.impl;

import cc.lzmsh.mapper.CategoryMapper;
import cc.lzmsh.pojo.Category;
import cc.lzmsh.pojo.result.Result;
import cc.lzmsh.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Author:   msh
 * Date:     2024/9/26 上午9:38
 * Description:
 */

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;
    @Override
    public Result addCategory(Category category) {
        categoryMapper.addCategory(category);
        return Result.success();
    }

    @Override
    public Result list(Integer userId) {
        return Result.success(categoryMapper.getCategoryList(userId));
    }

    @Override
    public Result getCategoryById(Integer id) {
        return Result.success(categoryMapper.getCategoryById(id));
    }

    @Override
    public Result updateCategory(Category category) {
        categoryMapper.updateCategory(category);
        return Result.success();
    }

    @Override
    public Result deleteCategory(Integer id) {
        categoryMapper.deleteCategory(id);
        return Result.success();
    }
}
